#include <gtest/gtest.h>

#include <QCoreApplication>

#include <Request/FileUploader.h>
#include <Server.h>
#include <Request/Login.h>
#include "privilege.h"

using namespace TC;
using namespace TC::Request;

TEST(Request_FileUploader, upload)
{
	obtainUserPrivilege();
	FileUploader uploader;
	uploader.uploadString("test_upload", "html");
	QObject::connect(&uploader, &FileUploader::error, [&]()
	{
		qWarning() << "Error : " << uploader.errorString();
	});
	while (FileUploader::Status::Communicating == uploader.status())
		QCoreApplication::processEvents();
	ASSERT_EQ(FileUploader::Status::Ok, uploader.status());
}

TEST(Request_FileUploader, upload_reverse)
{
	obtainUserPrivilege();
	FileUploader uploader;
	uploader.uploadData("test_upload", "exe");
	while (FileUploader::Status::Communicating == uploader.status())
		QCoreApplication::processEvents();
	ASSERT_EQ(FileUploader::Status::Failed, uploader.status());
}